

module Demo01 where

import Ochre.Compiler.Alpha
import Ochre.Compiler.Beta
import Ochre.Compiler.Compile ( compileOrchestra ) 
import Ochre.Compiler.CompilerMon
import Ochre.Compiler.ConstFold
import qualified Ochre.Compiler.CsoundSyntax as C
import Ochre.Compiler.ElimLet
import Ochre.Compiler.Operators
import Ochre.Compiler.Syntax
import Ochre.Compiler.VarId
import Ochre.TopLevel



demo01 = either putStr putStr $ compileOrchestra default_opts orch

orch = Orchestra [] [instr101]

instr101 = Instrument 101 [dec1] expr
  where
    avar = Local A_RATE 1
    ivar = DeclVar I_RATE "i1"
    dec1 = Decl ivar (Pfield 4)
    expr = LetSig1 avar 
                  (oscil (Var ivar) (Float 440.0) (Int 1))
                  (out (Signal avar))

oscil :: Value -> Value -> Value -> Expr
oscil amp hz tix = OpCall (PrimId "oscil") [amp,hz,tix]

out :: Value -> Expr
out v1 = OpCall (PrimId "out") [v1]